package com.hotelsystem.reservations.layouts;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

public class ClientImageSelect {
		
	private JFileChooser fileChooser;
	private JButton selectButton;
	private String selectedPath;
	public String getSelectedPath() {
		return selectedPath;
	}
	public JButton getSelectButton(final JFrame frame) {
		fileChooser = new JFileChooser();
		fileChooser.setApproveButtonText("Select");
		fileChooser.setAcceptAllFileFilterUsed(false);
		FileFilter jpgFilter = new FileNameExtensionFilter("JPEG", "jpg");
		FileFilter bmpFilter = new FileNameExtensionFilter("BMP", "bmp");
		FileFilter pngFilter = new FileNameExtensionFilter("PNG", "png");
		FileFilter icoFilter = new FileNameExtensionFilter("ICO", "png");
		fileChooser.addChoosableFileFilter(jpgFilter);
		fileChooser.addChoosableFileFilter(bmpFilter);
		fileChooser.addChoosableFileFilter(pngFilter);
		fileChooser.addChoosableFileFilter(icoFilter);
		selectButton = new JButton("Select Picture");
		selectButton.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				int returnVal = fileChooser.showDialog(frame, "Select Picture");
				if(returnVal==JFileChooser.APPROVE_OPTION) {
					selectedPath = fileChooser.getSelectedFile().getAbsolutePath();
				}
			}
		});
		return selectButton;
	}
}
